﻿using Ec_System.Models.Web;
using Ec_System.Service.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ec_System.Bll.Web
{
    public class IndexRecommendManager
    {
        IndexRecommendService indexRecommendService = new IndexRecommendService();
        VendorShopService vendorService = new VendorShopService();
        PromotionScheduleService promService = new PromotionScheduleService();

        /// <summary>
        /// 获取首页的信息
        /// </summary>
        /// <returns></returns>
        public IndexRecommendData GetIndexFloorData()
        {
            IndexRecommendData indexRecommendData = new IndexRecommendData();
            var indexRecommendList = indexRecommendService.GetIndexRecommend();
            //明星店铺
            indexRecommendData.ShopList = vendorService.GetTop9Shop();
            //促销数据
            indexRecommendData.ScheduleList = promService.GetTop9PromotionSchedule();
            indexRecommendData.ScheduleList.ForEach(item => item.ShopProductTitle = item.ShopProductTitle.Length > 10 ? item.ShopProductTitle.Substring(0, 10) : item.ShopProductTitle);


            indexRecommendData.F11 = indexRecommendList.Where(item => item.RecommendType == "Index-1-1").Take(4).ToList();//1F最新推荐
            indexRecommendData.F12 = indexRecommendList.Where(item => item.RecommendType == "Index-1-2").Take(4).ToList();//1F时令水果
            indexRecommendData.F13 = indexRecommendList.Where(item => item.RecommendType == "Index-1-3").Take(4).ToList();//1F时令蔬菜
            indexRecommendData.F2 = indexRecommendList.Where(item => item.RecommendType == "Index-2-0").Take(10).ToList();//2F最新水果推荐
            indexRecommendData.F3 = indexRecommendList.Where(item => item.RecommendType == "Index-3-0").Take(10).ToList();//3F最新蔬菜推荐
            indexRecommendData.F4 = indexRecommendList.Where(item => item.RecommendType == "Index-4-0").Take(10).ToList();//4F热卖商品
            indexRecommendData.F5 = indexRecommendList.Where(item => item.RecommendType == "Index-5-0").Take(10).ToList();//5F好评商品
            indexRecommendData.F6 = indexRecommendList.Where(item => item.RecommendType == "Index-6-0").Take(10).ToList();//6F销量最高商品

            return indexRecommendData;
        }
    }
}
